//https://www.nowcoder.com/practice/f0db4c36573d459cae44ac90b90c6212?tpId=182&tqId=34789&ru=/exam/oj
#include <iostream>
#include <string>
using namespace std;

//My:
string delete_str(const string& str1, const string& str2) {
    string ret;
    for (char ch1 : str1) {
        bool a = false;
        for (char ch2 : str2) {
            if (ch1 == ch2) {
                a = true;
                break;
            }
        }
        if (!a)
            ret += ch1;
    }
    return ret;
}

int main() {
    string a, b;
    getline(cin, a);
    getline(cin, b);
    cout << delete_str(a, b) << endl;

}

///////////////////////////////
#include <iostream>
#include <string>
using namespace std;
int main()
{
    string s, t;
    getline(cin, s);
    getline(cin, t);
    bool hash[300] = { 0 };
    for (char ch : t) hash[ch] = true;
    string ret;
    for (auto ch : s)
    {
        if (!hash[ch])
        {
            ret += ch;
        }
    }
    cout << ret << endl;
    return 0;
}


//https://www.nowcoder.com/practice/6ab1d9a29e88450685099d45c9e31e46?tpId=13&tqId=11189&ru=/exam/oj

//My:
class Solution {
public:
    int getlength(ListNode* p) {
        int x = 0;
        while (p) {
            x++;
            p = p->next;
        }
        return x;
    }
    ListNode* FindFirstCommonNode(ListNode* pHead1, ListNode* pHead2) {
        int len1 = getlength(pHead1);
        int len2 = getlength(pHead2);
        while (len1 > len2) {
            pHead1 = pHead1->next;
            len1--;
        }
        while (len1 < len2) {
            pHead2 = pHead2->next;
            len2--;
        }
        while (pHead1 && pHead2) {
            if (pHead1 == pHead2) {
                return pHead1;
            }
            pHead1 = pHead1->next;
            pHead2 = pHead2->next;
        }
        return nullptr;
    }
};


///////////////////

class Solution
{
public:
    ListNode* FindFirstCommonNode(ListNode* pHead1, ListNode* pHead2)
    {
        ListNode* cur1 = pHead1, * cur2 = pHead2;
        while (cur1 != cur2)
        {
            cur1 = cur1 != NULL ? cur1->next : pHead2;
            cur2 = cur2 != NULL ? cur2->next : pHead1;
        }
        return cur1;
    }
};


//https://ac.nowcoder.com/acm/problem/26226

#include <iostream>
#include <string>
using namespace std;
int n;
string str;
int main()
{
    cin >> n >> str;
    long long s = 0, h = 0, y = 0;
    for (int i = 0; i < n; i++)
    {
        char ch = str[i];
        if (ch == 's') s++;
        else if (ch == 'h') h += s;
        else if (ch == 'y') y += h;
}
    cout << y << endl;
    return 0;
}
